﻿Namespace Web
    Partial Public Class Neteja

#Region "Dates"

        Public Property strHoraObertura As String
            Get
                Return Right("00" & HoraObertura.Hours, 2) & ":" & Right("00" & HoraObertura.Minutes, 2) '& ":" & Right("00" & DataHora.Seconds, 2)
            End Get
            Set(value As String)
                Try
                    HoraObertura = TimeSpan.Parse(value)
                    RaisePropertyChanged("strHoraObertura")
                Catch ex As Exception
                    Throw New FormatException()
                End Try
            End Set
        End Property

        Public Property strHoraTancament As String
            Get
                If HoraTancament.HasValue Then
                    Return Right("00" & HoraTancament.Value.Hours, 2) & ":" & Right("00" & HoraTancament.Value.Minutes, 2) '& ":" & Right("00" & DataHora.Seconds, 2)
                Else
                    Return ""
                End If
            End Get
            Set(value As String)
                Try
                    If value = "" Then
                        HoraTancament = Nothing
                    Else
                        HoraTancament = TimeSpan.Parse(value)
                    End If
                    RaisePropertyChanged("strHoraTancament")
                Catch ex As Exception
                    Throw New FormatException()
                End Try
            End Set
        End Property

        Public Property strData As String
            Get
                Return Right("00" & Data.Day, 2) & "/" & Right("00" & Data.Month, 2) & "/" & Right("0000" & Data.Year, 4)
            End Get
            Set(value As String)
                Try
                    Data = Date.Parse(value)
                    RaisePropertyChanged("strData")
                Catch ex As Exception
                    Throw New FormatException()
                End Try
            End Set
        End Property

        Private Sub OnHoraOberturaChanged()
            RaisePropertyChanged("strHoraObertura")
        End Sub

        Private Sub OnHoraTancamentChanged()
            RaisePropertyChanged("strHoraTancament")
        End Sub

        Private Sub OnDataChanged()
            RaisePropertyChanged("strData")
        End Sub
#End Region

        Private Sub OnIdUsuariTancamentChanged()
            RaisePropertyChanged("EsTancat")
        End Sub
    End Class
End Namespace
